import requests

from common.get_headers_util import get_headers
from common.get_id_util import get_id_until


class IhrmEmploeeApi:
    #员工添加
    @classmethod
    def ihrm_emploee_insert_api(cls,json_data):
        em_insert_resp = requests.post(url="http://ihrm2-test.itheima.net/api/sys/user",
                                       headers=get_headers(),
                                       json=json_data)
        return em_insert_resp
    #员工修改
    @classmethod
    def ihrm_emploee_update_api(cls, json_data):
        em_update_resp = requests.put(url=f"http://ihrm2-test.itheima.net/api/sys/user/{get_id_until()}",
                                       headers=get_headers(),
                                       json=json_data)
        return em_update_resp
#员工删除
    @classmethod
    def ihrm_emploee_delete_api(cls):
        delete_resp=requests.delete(url=f"http://ihrm2-test.itheima.net/api/sys/user/{get_id_until()}",
                                    headers=get_headers())
        return delete_resp

    #员工查询
    @classmethod
    def ihrm_emploee_select_api(cls,target):
        select_resp=requests.get(url=f"http://ihrm2-test.itheima.net/api/sys/user/{target}",
                                 headers=get_headers())
        return select_resp
